#include <iostream>
#include <cstring>
using namespace std;

#define MAX_N 100000
int darkness[MAX_N + 5];
int dp[MAX_N + 5];
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) 
        cin >> darkness[i];
    memset(dp, 0, sizeof dp);
    int ret = -0x3f3f3f3f;
    for(int i = 2; i < n; i++)
    {
        //选择当前的黑暗
        int pre;
        if(i - 3 < 0) pre = 0;
        else pre = i - 3;
        dp[i] = darkness[i] + dp[pre];
        //和不选取较大值
        dp[i] = max(dp[i - 1], dp[i]);
        ret = max(ret, dp[i]);
    }
    // for(int i = 1; i <= n; i++)
    // {
    //     cout << dp[i] << " ";
    // }
    // cout << endl;
    cout << ret;
    return 0;
}